package com.yc.springmvc.controller;

import javax.servlet.http.HttpSession;

import com.yc.springmvc.core.annotation.*;


import com.yc.springmvc.bean.UserInfo;
import com.yc.springmvc.service.IUserInfoService;

import java.util.List;
import java.util.Map;

@Controller//说明是控制层
@RequestMapping("/user")//这个控制层中的方法的访问路径
public class UserInfoController {
	@Autowired
	private IUserInfoService userInfoService;
	
	@RequestMapping("/login")
	@ResponseBody//说明以json格式返回给前端
	public UserInfo login(UserInfo uf,HttpSession session) {
		System.out.println(uf);
		UserInfo user = userInfoService.login(uf);
		session.setAttribute("currentUser", user);
		return uf;
	}

	@RequestMapping("/finds")
	@ResponseBody//说明以json格式返回给前端
	public List<UserInfo> login(String usid,String uname,int age,String tel) {
		System.out.println(usid + uname + age + tel);
		return userInfoService.finds();
	}

	@RequestMapping("/find1")
	@ResponseBody//说明以json格式返回给前端
	public Map<String,Object> find1(Map<String,Object> map) {
		System.out.println(map);
		return map;
	}

	@RequestMapping("/find2")
	@ResponseBody//说明以json格式返回给前端
	public UserInfo find2(UserInfo uf,Integer age) {
		System.out.println(uf);
		System.out.println(age);
		return uf;
	}

	@RequestMapping("/find2")

	public String find3(UserInfo uf,Integer age) {
		System.out.println(uf);
		System.out.println(age);
		return "success.html";
	}
}
